/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CustomerInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.db.ImportantDateManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ListImportantDates extends AbstractAction
/*    */ {
/* 33 */   private static Logger logger = Logger.getLogger(ListImportantDates.class
/* 34 */     .getName());
/*    */ 
/*    */   public ListImportantDates(AbstractHttpServlet servlet)
/*    */   {
/* 37 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 43 */     response.setContentType("text/html;charset=utf-8");
/* 44 */     PrintWriter out = response.getWriter();
/* 45 */     int customerId = Util.getURLIntParameter(request
/* 46 */       .getParameter("CustomerId"));
/*    */ 
/* 48 */     User user = super.getLoginUser(request);
/* 49 */     if (!user.isAdmin)
/*    */     {
/* 51 */       CustomerManager customerManager = new CustomerManager();
/*    */       try {
/* 53 */         CustomerInfo customerInfo = customerManager.getCustomerInfo(
/* 54 */           customerId, false, false);
/* 55 */         if ((customerInfo == null) || 
/* 57 */           (!customerInfo.hasViewRight(user, 
/* 57 */           super.getCompany(user.companyId)))) {
/* 58 */           showErrorMessage(response, 
/* 59 */             "您没有查看该客户的权限");
/* 60 */           return;
/*    */         }
/*    */       } catch (DBException e) {
/* 63 */         logger.warn("get importantdate failed", e);
/*    */ 
/* 65 */         showErrorMessage(response, "您没有查看该客户的权限");
/* 66 */         return;
/*    */       }
/*    */     }
/*    */ 
/* 70 */     ImportantDateManager manager = new ImportantDateManager();
/* 71 */     JSONObject jsonObject = new JSONObject();
/* 72 */     List result = manager.list(customerId);
/* 73 */     if (result == null) {
/* 74 */       jsonObject.put("error", "1");
/*    */     } else {
/* 76 */       jsonObject.put("error", "0");
/* 77 */       jsonObject.put("importantDates", result);
/*    */     }
/* 79 */     out.println(jsonObject);
/* 80 */     out.flush();
/* 81 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ListImportantDates
 * JD-Core Version:    0.6.1
 */